﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcps.Web.supplierinfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int ID=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(ID);
				}
			}
		}
			
	private void ShowInfo(int ID)
	{
		lcps.BLL.supplierinfo bll=new lcps.BLL.supplierinfo();
		lcps.Model.supplierinfo model=bll.GetModel(ID);
		this.lblID.Text=model.ID.ToString();
		this.txtsupplyname.Text=model.supplyname;
		this.txtsuppliername.Text=model.suppliername;
		this.txtsupplierphone.Text=model.supplierphone;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtsupplyname.Text.Trim().Length==0)
			{
				strErr+="supplyname不能为空！\\n";	
			}
			if(this.txtsuppliername.Text.Trim().Length==0)
			{
				strErr+="suppliername不能为空！\\n";	
			}
			if(this.txtsupplierphone.Text.Trim().Length==0)
			{
				strErr+="supplierphone不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int ID=int.Parse(this.lblID.Text);
			string supplyname=this.txtsupplyname.Text;
			string suppliername=this.txtsuppliername.Text;
			string supplierphone=this.txtsupplierphone.Text;


			lcps.Model.supplierinfo model=new lcps.Model.supplierinfo();
			model.ID=ID;
			model.supplyname=supplyname;
			model.suppliername=suppliername;
			model.supplierphone=supplierphone;

			lcps.BLL.supplierinfo bll=new lcps.BLL.supplierinfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
